function save() {
    let data = new FormData();
    data.append("houseId", $("#houseId").val());
    data.append("name", $("#productName").val());
    data.append("marketPrice", $("#marketPrice").val());
    data.append("normalPrice", $("#normalPrice").val());
    // data.append("example", $("#example").val());
    // data.append("navImg", $("#navImg")[0].files[0]);
    data.append("status", $("input:radio[name='status']:checked").val());
    //拿到的图片有可能是一组数据，[0].files[0]选中当前对象的第一个数据
    data.append("img", $("#img")[0].files[0]);
    data.append("description",edit.txt.html());
    let result = myImgAjax("/adminFile/product/add", data,"post");
    console.log(result);
    if(result.result == "success"){
        alert("新增成功（== ^^ ==）！")
        $(".right").load("/html/admin/product/productManage.html");
    }else if(result.result == "noLogin"){
        window.open("/html/login.html","_self");
    }else{
        alert("新增失败！");
    }
}
function goBack() {
    $('.right').load('/html/admin/product/productManage.html');
}

/**
 * 判断上传图片大小格式是否符合要求
 */


//图片类型验证
function validationSize(file) {
    var fileTypes = [".jpg", ".png"];
    var filePath = file.value;
    //当括号里面的值为0、空字符、false 、null 、undefined的时候就相当于false
    if(filePath){
        var isNext = false;
        var fileEnd = filePath.substring(filePath.indexOf("."));
        for (var i = 0; i < fileTypes.length; i++) {
            if (fileTypes[i] == fileEnd) {
                isNext = true;
                break;
            }
        }
        if (!isNext){
            alert('不接受此文件类型');
            file.value = "";
            return false;
        }
    }else {
        return false;
    }
}

//图片大小验证
function validationSize(file) {

    var fileMaxSize = (1024 * 5);//5M
    var filePath = file.value;
    if(filePath){
        fileSize =file.files[0].size;
        var size = fileSize / 1024;
        if (size > fileMaxSize) {
            alert("文件大小不能大于1M！");
            file.value = "";
            return false;
        }else if (size <= 0) {
            alert("文件大小不能为0M！");
            file.value = "";
            return false;
        }
    }else{
        return false;
    }
}